<template>
	<!-- 培训信息 -->
	<view class="pxxx-list">
		<!-- 有数据时显示列表 -->
		<view class="row" v-for="(item, index) in pxxxData" :key="index" @click="handleClick(item)">
			<view class="left">
				<image :src="item.peixunTp" mode="aspectFit"></image>
			</view>
			<view class="right">
				<view class="title">{{ item.peixunTitle }}</view>
				<view class="business">{{ item.peixunInfo }}</view>
				<view class="view-count">
					<!-- <uni-icons type="eye" size="14"></uni-icons>
					<view class="uni-icons-text">
						{{ item.xyyfServiceLookList && item.xyyfServiceLookList.length || 0 }}
					</view> -->
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		name: "Pxxx",
		data() {
			return {

			};
		},
		props: {
			pxxxData: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			handleClick(item) {
				// 检查登录状态
				if (!this.$store.state.user.isLoggedIn) {
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					});
					// 跳转到登录页面
					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/login/login'
						});
					}, 1500);
					return;
				}
				uni.navigateTo({
					url: `/pages/service-provider-details/service-provider-details?peixunTitle=${item.peixunTitle}&text='培训信息'`
				});
			}
		}
	}
</script>

<style lang="less">
	// 培训资源
	.pxxx-list {
		margin-top: 10rpx;
		padding: 0 30rpx;

		.row {
			position: relative;
			display: flex;
			padding: 30rpx 0 20rpx;

			&::after {
				content: '';
				position: absolute;
				left: 0;
				bottom: 0;
				width: 100%;
				height: 1rpx;
				background: #f3f3f3;
			}

			&:last-child {
				&::after {
					display: none;
				}
			}

			.left {
				flex-shrink: 0;
				height: 180rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;

				image {
					width: 240rpx;
					height: 180rpx;
				}

			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				margin-left: 30rpx;

				.title {
					font-size: 32rpx;
					color: #000;
					font-weight: bold;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.business {
					min-height: 95rpx;
					font-size: 28rpx;
					color: #444;
					margin-top: 20rpx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 3;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.view-count {
					display: flex;
					align-items: center;
					justify-content: flex-end;
					font-size: 24rpx;
					color: #666;
					margin-top: 5rpx;

					.uni-icons-text {
						margin-left: 10rpx;
					}
				}

			}



		}
	}

	// 添加无数据样式
	.zwxx-img {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 100rpx 0;

		image {
			width: 300rpx;
		}

		view {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999;
		}
	}
</style>